from selenium.webdriver.common.by import By

from Driver.Driver import MDriver
from part import BarFace
class PersonalCenterFace:
    driver=''
    def __init__(self):
        self.driver=MDriver.driver
    # 进入个人中心
    def Come(self):
        BarFace.BarFace().Come()
        BarFace.BarFace().BarHead()
        BarFace.BarFace().BarGotoPersonalCenter()
        self.driver.execute_script("document.body.style.zoom='0.5'")
    # 方便写代码
    def QFind(self,name):
        self.driver.find_element(By.CSS_SELECTOR,name)
    # 元素检测
    def PersonalCenterFace(self):
        # 用户中心的文字
        self.QFind("#bit-forum-content > div.page-header.d-print-none > div > div > div > h2")
        # 我的账户分栏
        self.QFind("#bit-forum-content > div.page-body > div > div > div > div.col-3.d-none.d-md-block.border-end > div > div > a")
        # 姓名
        self.QFind("#settings_nickname")
        # 头像
        self.QFind("#settings_avatar")
        # 必须填写的提示*号
        self.QFind("#bit-forum-content > div.page-body > div > div > div > div.col.d-flex.flex-column > div > div:nth-child(14) > div > div > form > div:nth-child(1) > label")
        # 修改头像按钮
        self.QFind("#bit-forum-content > div.page-body > div > div > div > div.col.d-flex.flex-column > div > div.row.align-items-center > div:nth-child(2) > a")
        # 昵称输入框及按钮
        self.QFind("#setting_input_nickname")
        self.QFind("#setting_submit_nickname")
        # 邮箱地址输入框及按钮
        self.QFind("#setting_input_email")
        self.QFind("#setting_submit_email")
        # 电话号码输入框及按钮
        self.QFind("#setting_input_phoneNum")
        self.QFind("#setting_submit_phoneNum")
        # 显示密码按钮
        self.QFind("#bit-forum-content > div.page-body > div > div > div > div.col.d-flex.flex-column > div > div:nth-child(14) > div > div > form > div:nth-child(1) > div > span > a > svg")
        # 原密码输入框
        self.QFind("#settings_input_oldPassword")
        # 新密码输入框
        self.QFind("#settings_input_newPassword")
        # 确认密码输入框
        self.QFind("#settings_input_passwordRepeat")
        # 确认修改按钮
        self.QFind("#settings_submit_password")
        #个人简介输入框及按钮
        self.QFind("#settings_textarea_remark")
        self.QFind("#settings_submit_remark")
    # 输入昵称
    def PersonalCenterScanfName(self,name):
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_nickname").send_keys(name)
    # 输入邮箱地址
    def PersonalCenterScanfEmail(self,email):
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_email").send_keys(email)
    # 输入电话号码
    def PersonalCenterScanfPhone(self,phone):
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_phoneNum").send_keys(phone)
    # 输入原密码
    def PersonalCenterScanfOldPass(self,oldpass):
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_oldPassword").send_keys(oldpass)
    # 输入新密码
    def PersonalCenterScanfNewPass(self,newpass):
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_newPassword").send_keys(newpass)
    # 输入确认新密码
    def PersonalCenterScanfAgainPass(self,againpass):
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_passwordRepeat").send_keys(againpass)
    # 输入个人简介
    def PersonalCenterScanfShot(self,shot):
        self.driver.find_element(By.CSS_SELECTOR,"#settings_textarea_remark").send_keys(shot)
    # 清空昵称输入框
    def PersonalCenterDeleteName(self):
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_nickname").clear()
    # 清空邮箱输入框
    def PersonalCenterDeleteEmail(self):
        self.driver.find_element(By.CSS_SELECTOR, "#setting_input_email").clear()
    # 清空电话号码输入框
    def PersonalCenterDeletePhone(self):
        self.driver.find_element(By.CSS_SELECTOR, "#setting_input_phoneNum").clear()
    # 清空原密码输入框
    def PersonalCenterDeleteOldPass(self):
        self.driver.find_element(By.CSS_SELECTOR, "#settings_input_oldPassword").clear()
    # 清空新密码输入框
    def PersonalCenterDeleteNewPass(self):
        self.driver.find_element(By.CSS_SELECTOR, "#settings_input_newPassword").clear()
    # 清空确认密码输入框
    def PersonalCenterDeleteAgainPass(self):
        self.driver.find_element(By.CSS_SELECTOR, "#settings_input_passwordRepeat").clear()
    # 清空个人简介
    def PersonalCenterDeleteShot(self):
        self.driver.find_element(By.CSS_SELECTOR, "#settings_textarea_remark").clear()
    # 点击修改昵称
    def PersonalCenterChangeName(self):
        self.driver.find_element(By.CSS_SELECTOR,"#setting_submit_nickname").click()
    # 点击修改邮箱
    def PersonalCenterChangeEmail(self):
        self.driver.find_element(By.CSS_SELECTOR,"#setting_submit_email").click()
    # 点击修改电话
    def PersonalCenterChangePhone(self):
        self.driver.find_element(By.CSS_SELECTOR,"#setting_submit_phoneNum").click()
    # 点击修改密码
    def PersonalCenterChangePass(self):
        self.driver.find_element(By.CSS_SELECTOR,"#settings_submit_password").click()
    # 点击修改个人简介
    def PersonalCenterChangeShot(self):
        self.driver.find_element(By.CSS_SELECTOR,"#settings_submit_remark").click()